package org.chl.chapter07.dao;

import java.util.List;

import org.chl.chapter07.model.Book;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;
import org.springframework.web.bind.annotation.CrossOrigin;

@CrossOrigin
public interface BookDao extends JpaRepository<Book, Integer>{
    List<Book> getBooksByAuthorStartingWith(@Param("author") String author);
    List<Book> getBooksByPriceGreaterThan(@Param("price") Float price);
//    @Query(value = "select * from t_book where id=(select max(id) from t_book)",nativeQuery = true)
//    Book getMaxIdBook();
//    @Query("select b from t_book b where b.id>:id and b.author=:author")
//    List<Book> getBookByIdAndAuthor(@Param("author") String author, @Param("id") Integer id);
//    @Query("select b from t_book b where b.id<?2 and b.name like %?1%")
//    List<Book> getBooksByIdAndName(String name, Integer id);
    
    // 屏蔽对外rest接口 exported = false
	@Override
	@RestResource(exported = false)
	void flush();
    
}
